import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 无状态的组件
abstract class BaseWidget extends StatelessWidget {
  const BaseWidget({super.key});

  Widget setContent(BuildContext context);

  @override
  Widget build(BuildContext context) {
    return WidgetsApp(
      debugShowCheckedModeBanner: false,
      color: Colors.white,
      builder: (context, build) {
        ScreenUtil.init(context, designSize: Size(750, 1334));
        return SafeArea(
          child: Container(color: Colors.white, width: 750.w, child: setContent(context)),
        );
      },
    );
  }
}

/// 有状态的组件
abstract class BaseStateWidget extends StatefulWidget {
  const BaseStateWidget({super.key});

  BaseState buildState();

  @override
  State createState() {
    return buildState();
  }
}

/// 状态
abstract class BaseState<T extends BaseStateWidget> extends State<T> {
  Widget setContent(BuildContext context);

  @override
  Widget build(BuildContext context) {
    SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    return WidgetsApp(
      debugShowCheckedModeBanner: true,
      color: Colors.white,
      builder: (context, build) {
        ScreenUtil.init(context, designSize: Size(750, 1334));
        return SizedBox(width: 750.w, child: setContent(context));
      },
    );
  }
}
